import request from '@/utils/request'

export function getEmployeeList(params) {
  return request({
    url: '/sys/user',
    params // 地址参数 查询参数
  })
}

/**
 * 导出员工的excel
 * **/

export const exportExcel = () => request.get('/sys/user/export', { responseType: 'blob' })
// 上传excel
export const uploadFile = (data) => request.post('/sys/user/import', data)
// excel模板下载
export const getImportExcel = () => request.get('/sys/user/import/template', {
  responseType: 'blob'
})

/**
 * 删除员工
 * **/
export function delEmployee(id) {
  return request({
    method: 'delete',
    url: `/sys/user/${id}`
  })
}

/* 新增员工 */
export function addEmployee(data) {
  return request({
    url: '/sys/user',
    method: 'post',
    data
  })
}

/* 获取员工信息 */
export const getEmployeeDetail = (id) => request.get(`/sys/user/${id}`)

/* 编辑员工 */

export function updateEmployee(data) {
  return request({
    url: `/sys/user/${data.id}`,
    method: 'put',
    data
  })
}

/**
 * 获取可用的角色
 * **/

export function getEnableRoleList() {
  return request({
    url: '/sys/role/list/enabled'
  })
}
/**
 * 分配员工角色
 * ***/

export function assignRole(data) {
  return request({
    url: '/sys/user/assignRoles',
    method: 'put',
    data
  })
}
